package leetcode.code0538;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;
import leetcode.helper.tree.TreeArray;
import leetcode.helper.tree.TreeNode;

public abstract class Solution538 implements IDebug {

	public abstract TreeNode convertBST(TreeNode root);

	@Override
	public void debug1() {
		String str = "[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]";
		TreeNode root = TreeArray.array2tree(HelpDebug.str2array4(str));
		TreeNode r = this.convertBST(root);
		str = "[30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]";
		TreeNode e = TreeArray.array2tree(HelpDebug.str2array4(str));
		HelpDebug.compare(e, r);
	}

	@Override
	public void debug2() {
		String str = "[0,null,1]";
		TreeNode root = TreeArray.array2tree(HelpDebug.str2array4(str));
		TreeNode r = this.convertBST(root);
		str = "[1,null,1]";
		TreeNode e = TreeArray.array2tree(HelpDebug.str2array4(str));
		HelpDebug.compare(e, r);
	}

	@Override
	public void debug3() {
		String str = "[1,0,2]";
		TreeNode root = TreeArray.array2tree(HelpDebug.str2array4(str));
		TreeNode r = this.convertBST(root);
		str = "[3,3,2]";
		TreeNode e = TreeArray.array2tree(HelpDebug.str2array4(str));
		HelpDebug.compare(e, r);
	}

	@Override
	public void debug4() {
		String str = "[3,2,4,1]";
		TreeNode root = TreeArray.array2tree(HelpDebug.str2array4(str));
		TreeNode r = this.convertBST(root);
		str = "[7,9,4,10]";
		TreeNode e = TreeArray.array2tree(HelpDebug.str2array4(str));
		HelpDebug.compare(e, r);
	}

}
